import React from 'react'
import { createBrowserRouter, Navigate } from 'react-router-dom'

import Index from '../components/szh/Index'
import Home from '../components/szh/Home'
import Cart from '../components/Lin/cart.jsx'
import My from '../components/Lin/My.jsx'
import Address from "../components/Lin/Address.jsx";
import Mydingd from "../components/Lin/Mydingd.jsx"
import Login from '../components/szh/Login.jsx'
import Register from '../components/szh/Register.jsx'
import Daifukuan from '../components/Lin/Daifukuan.jsx'
import Daifahuo from '../components/Lin/Daishouhuo.jsx' 
import Yiwancheng from '../components/Lin/Yiwancheng.jsx' 
import Pingjia from '../components/Lin/Pingjia.jsx' 
import Myshoucang from '../components/Lin/Myshoucang.jsx' 
import Yijian from '../components/Lin/Yijian.jsx' 
import Daishouhuo from '../components/Lin/Daishouhuo.jsx' 
import Addaddress from '../components/Lin/Addaddress.jsx' 
import Ziliao from '../components/Lin/Ziliao.jsx' 
import Qerendingdan from '../components/Lin/Qerendingdan.jsx'
import Px from '../components/Lin/Px.jsx'
import Xq from '../components/Lin/Xq.jsx'
import GetPassword from '../components/szh/GetPassword.jsx'
import Plogin from '../components/szh/Plogin.jsx'
import FaceLogin from '../components/szh/FaceLogin.jsx'
import Header from '../components/lmy/Header.jsx'
import Fen from '../components/lmy/Fen.jsx'
import Show from '../components/lmy/Show.jsx'
import Search from "../components/lmy/Search.jsx";
import Orders from '../components/lmy/Orders.jsx';
import Customer from '../components/lmy/Customer.jsx'


const Islogin =(val)=>{
    let Com = val.children.type;
    if(localStorage.getItem('accessToken')){
        return <Com></Com>
    }else{
        return <Navigate to='/login'></Navigate>
    }
}

const router = createBrowserRouter([
  { path: "/", element: <Navigate to={"/login"}></Navigate> },
  {
    path: "/index",
    element: <Index />,
    children: [
      { path: "home", element: <Home></Home> },
      { path: "cart", element: <Cart></Cart> },
      { path: "my", element: <My></My> },
      {path:'cate',element:<Fen/>},
    ],
  },
  { path: "/search", element: <Search></Search> },
  { path: "/address", element: <Address></Address> },
  { path: "/mydingd", element: <Mydingd></Mydingd> },
  { path: "/header", element: <Header></Header> },
  { path: "/customer", element: <Customer></Customer> },
  { path: "/orders", element: <Orders></Orders> },
  { path: "/fen", element: <Fen></Fen> },
  { path: "/show", element: <Show></Show> },
  { path: "/daifukuan", element: <Daifukuan></Daifukuan> },
  { path: "/plogin", element: <Plogin /> },
  { path: "/facelogin", element: <FaceLogin /> },
  { path: "/login", element: <Login></Login> },
  { path: "/register", element: <Register></Register> },
  { path: "/getpassword", element: <GetPassword></GetPassword> },
  { path: "/daifahuo", element: <Daifahuo></Daifahuo> },
  { path: "/yiwancheng", element: <Yiwancheng></Yiwancheng> },
  { path: "/pingjia", element: <Pingjia></Pingjia> },
  { path: "/myshoucang", element: <Myshoucang></Myshoucang> },
  { path: "/yijian", element: <Yijian></Yijian> },
  { path: "/daishouhuo", element: <Daishouhuo></Daishouhuo> },
  { path: "/addaddress", element: <Addaddress></Addaddress> },
  { path: "/ziliao", element: <Ziliao></Ziliao> },
  { path: "/px", element: <Px></Px> },
  { path: "/xq", element: <Xq></Xq> },
  {path: "/qerendingdan", element: <Qerendingdan></Qerendingdan>}
]);

    


export default router;